import fly from '@/utils/fly'

var workerApi = {
  /**
   * 注册
   */
  save: function(username, password) {
    return fly.post('/api/aierp/v1/user/save', {
      username: username,
      password: password
    })
  },
  /**
   * 更新工人基本信息
   */
  update: function(workerForm) {
    return fly.post('/api/aierp/v1/user/update', workerForm)
  },
  /**
   * 更新工人认证基本信息
   */
  updateWorkerAuth: function(workerForm) {
    return fly.post('/api/aierp/v1/user/updateWorkerAuth', workerForm)
  },
  /**
   * 编辑安装类目
   */
  updateWorkType: function(workType) {
    return fly.post('/api/aierp/v1/user/update', workType)
  },

  /**
   * 根据工人id，查询该工人覆盖市的集合
   */
  findOverCitysById: function(param) {
    return fly.post('/api/aierp/v1/user/findOverCitysById', param)
  },
  /**
   * 根据工人id查询工人信息
   */
  getWorkerById: function(param) {
    return fly.post('/api/aierp/v1/user/getWorkerById', param)
  },

  /**
   * 根据工人id查询工人认证信息
   */
  getWorkerAuthById: function(id) {
    console.log(id)
    // return fly.post('/api/aierp/v1/user/getWorkerAuthById', )
    return fly.request(
      '/api/aierp/v1/user/getWorkerAuthById',
      { id : id },
      {
        method: 'post',
        timeout: 5000 //超时设置为5s
      }
    )
  },

  getCitysByParent: function(param) {
    return fly.post('/api/aierp/v1/user/findCitysByParentCode', param)
  },
  updateOverById(param) {
    return fly.post('/api/aierp/v1/user/updateOverById', param)
  },
  findAllSubCitysByParentCode(param) {
    return fly.post('/api/aierp/v1/user/findAllSubCitysByParentCode', param)
  }
  // export function updateOverById(workerId, over) {
  //   var params = { 'workerId': workerId, 'over': over }
  //findAllSubCitysByParentCode
  //   return request({
  //     url: '/backadmin/workerManage/worker/updateOverById',
  //     method: 'post',
  //     params
  //   })
  // }
  // 根据父级id获取区域信息
  // export function getCitysByParent(params) {
  //   return request({
  //     url: '/backadmin/code/citys/findCitysByParentCode',
  //     method: 'post',
  //     params
  //   })
  // }
  // export function findOverCitysById(params) {
  //   return request({
  //     url: '/backadmin/workerManage/worker/findOverCitysById',
  //     method: 'post',
  //     params
  //   })
  // }
}

export { workerApi }
